package com.iims.framework.interceptor;

import com.iims.common.utils.SecurityUtils;
import com.iims.framework.redis.RepeatRequestComponent;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 登录用户请求防重发处理,Order=0优先于RedissonLockAspect
 * 暂时未使用
 *
 * @author fanpei
 * @date 2020年3月24日
 */
//@Aspect
//@ConditionalOnBean(RepeatRequestComponent.class)
//@Order(0)
@Deprecated
public class RepeatRequestAspect {
    @Autowired
    private RepeatRequestComponent repeatRequestComponent;

    @Pointcut("execution(* com.*..*.controller.*.*(..))")
    private void controllerAspect() {
    }

    @Around("controllerAspect()")
    public Object controllerAspectAround(ProceedingJoinPoint joinPoint) throws Throwable {
        return repeatRequestComponent.exec(joinPoint, SecurityUtils.getUsername());
    }
}
